package todomanager.View;
/**
*
* @author Gi-Hoon
*/

import java.util.*;
import java.awt.*;

import javax.swing.*;
import javax.swing.table.*;

public class ProgressCellRenderer extends JProgressBar implements TableCellRenderer {

	public ProgressCellRenderer() {
		super(JProgressBar.HORIZONTAL);
		setBorderPainted(false);
	}

	public ProgressCellRenderer(int min, int max) {
		super(JProgressBar.HORIZONTAL, min, max);
		setBorderPainted(false);
	}
	

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
		// TODO Auto-generated method stub
		int n = 0;
	    if (! (value instanceof Number)) {
	      String str;
	      if (value instanceof String) {
	        str = (String)value;
	      } else {
	        str = value.toString();
	      }
	      try {
	        n = Integer.valueOf(str).intValue();
	      } catch (NumberFormatException ex) {
	      }
	    } else {
	      n = ((Number)value).intValue();
	    }
	    setValue(n);
	    
	    return this;
	}
}
